package com.cx.heima.util;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * @program: pms
 * @author: cx
 * @description:
 * @create: 2024-11-12 14:29
 **/
public class JedisPoolUtil {
    private static final JedisPool jedispool;
    static {
        //配置连接池
        JedisPoolConfig poolConfig = new JedisPoolConfig();
        //最大连接数
        poolConfig.setMaxTotal(8);
        //最大空闲连接
        poolConfig.setMaxIdle(8);
        //最小空闲连接
        poolConfig.setMinIdle(2);
        //等待时长
        poolConfig.setMaxWaitMillis(1000);
        //创建连接对象
        jedispool = new JedisPool(poolConfig, "106.14.61.26", 6379, 1000, "123456");
    }
    public static Jedis getJedis() {
        return jedispool.getResource();
    }

}